Skip to content

feat(config): support opencode.local.json for project-local config overrides#17234

Open
webrgp wants to merge 1 commit intoanomalyco:devfrom
webrgp:feat/local-config-overrides
Open

feat(config): support opencode.local.json for project-local config overrides#17234
webrgp wants to merge 1 commit intoanomalyco:devfrom
webrgp:feat/local-config-overrides

Conversation

@webrgp
Copy link

@webrgp webrgp commented Mar 12, 2026

Issue for this PR

Closes #17232

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds opencode.local.json and opencode.local.jsonc as a new config layer for machine-specific overrides that can be safely gitignored. This gives users a clean way to keep secrets (API keys, custom endpoints) or machine-specific settings out of version control without modifying the shared opencode.json.

The local config files slot between project config and .opencode directories in the precedence order:

  1. Remote .well-known/opencode
  2. Global ~/.config/opencode/opencode.json
  3. OPENCODE_CONFIG
  4. Project opencode.json (committed)
  5. Project opencode.local.json (NEW — gitignored)
  6. .opencode directories
  7. OPENCODE_CONFIG_CONTENT

Implementation reuses the existing ConfigPaths.projectFiles() helper parameterized with "opencode.local" — this naturally discovers both .json and .jsonc variants using the same Filesystem.findUp walk-up logic, so no changes to path resolution were needed. Loading is gated by the same OPENCODE_DISABLE_PROJECT_CONFIG flag as regular project config.

Changes:

  • packages/opencode/src/config/config.ts — 4 lines to load local config files after project config, updated precedence comment
  • packages/opencode/test/config/config.test.ts — 7 tests covering JSON/JSONC loading, precedence over project config, .opencode/ overrides local, disabled-by-flag, array merging, and loading when gitignored
  • packages/web/src/content/docs/config.mdx — updated precedence list and added "Local overrides" section with examples

How did you verify your code works?

Added 7 unit tests in packages/opencode/test/config/config.test.ts under a describe("opencode.local.json") block. All tests pass locally via bun test from packages/opencode. Existing tests remain green (one pre-existing failure in permission config preserves key order is unrelated).

Screenshots / recordings

N/A — no UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

…errides

Adds opencode.local.json and opencode.local.jsonc as a new config layer
between project config and .opencode directories. Intended to be
gitignored for machine-specific settings like API keys or model
preferences without modifying the shared project config.
@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Mar 12, 2026
@github-actions
Copy link
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Support opencode.local.json for project-local config overrides

1 participant